$(function () {
    let markid = getUrlString('markid');
    let source = getUrlString('source');
    let kutoysids = getUrlString('kutoysids');
    $('#orderBtn').click(function () {
        let name = $('#name').val();
        let phone = $('#phone').val();
        let addressDetail = $('#addressDetail').val();
        let options1 = $("#local1 option:selected").attr('data-code'); //获取选中的项
        let options2 = $("#local2 option:selected").attr('data-code'); //获取选中的项
        let options3 = $("#local3 option:selected").attr('data-code'); //获取选中的项
        console.log(options2)
        if (name === ''){
            laymsg('请输入姓名');
            return
        }
        if (!phoneNumberVer(phone)){
            return;
        }

        if (options1 === ''){
            laymsg('请选择省');
            return
        }

        if (options2 === ''){
            laymsg('请选择市');
            return
        }

        // if (options3 === ''){
        //     laymsg('请选择区');
        //     return
        // }

        if (addressDetail === ''){
            laymsg('请输入详细地址');
            return
        }

        let data = {
            'markid':markid,
            'type':1,
            'phone':phone,
            'address':addressDetail,
            'adid':'',
            'remark':'add',
            'local1':options1,
            'local2':options2,
            'local3':options3,
            'name':name,
        };

        getData('post','/niu/apiv3/fahuo_address_add.php',data,function (data) {
            console.log(data);
            laymsg('添加地址成功');
            if (source === 'shipments'){
                setTimeout(function () {
                    window.location.href = document.referrer;//返回上一页并刷新
                },500)

            }else {
                setTimeout(function () {
                    nativeCommand("dancool://activity=reflashfin")
                },500)
            }
        })
    })
});
